package com.cn.mapper;

import com.cn.dao.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    /**
     * delete by primary key
     * @param nickname primaryKey
     * @return deleteCount
     */
    int deleteByPrimaryKey(@Param("nickname") String nickname, @Param("email") String email);

    /**
     * insert record to table
     * @param record the record
     * @return insert count
     */
    int insert(User record);

    /**
     * insert record to table selective
     * @param record the record
     * @return insert count
     */
    int insertSelective(User record);

    /**
     * select by primary key
     * @param nickname primary key
     * @return object by primary key
     */
    User selectByPrimaryKey(@Param("nickname") String nickname, @Param("email") String email);

    /**
     * update record selective
     * @param record the updated record
     * @return update count
     */
    int updateByPrimaryKeySelective(User record);

    /**
     * update record
     * @param record the updated record
     * @return update count
     */
    int updateByPrimaryKey(User record);
    /**
     * 根据用户邮件获取用户信息
     */
    @Select("select * from User where email = #{email} ")
    User selectUserByEmail(String email);
    @Select("select * from User")
    List<User> selectUserAll();
}